using System;
using System.Collections.Generic;
using System.Text;

namespace BusinessEntities
{
    public class Raiders : List<Raider>
    {
        #region Fields 

        private string _raiderNameToFind;

        #endregion

        #region Properties

        public int WarriorCount
        {
            get
            {
                return CountClassMembers(1);
            }
        }

        public int PaladinCount
        {
            get
            {
                return CountClassMembers(2);
            }
        }

        public int HunterCount
        {
            get
            {
                return CountClassMembers(3);
            }
        }
        
        public int RogueCount
        {
            get
            {
                return CountClassMembers(4);
            }
        }

        public int PriestCount
        {
            get
            {
                return CountClassMembers(5);
            }
        }
        
        public int ShamanCount
        {
            get
            {
                return CountClassMembers(7);
            }
        }
        
        public int MageCount
        {
            get
            {
                return CountClassMembers(8);
            }
        }

        public int WarlockCount
        {
            get
            {
                return CountClassMembers(9);
            }
        }

        public int DruidCount
        {
            get
            {
                return CountClassMembers(11);
            }
        }

        #endregion

        #region Methods
        
        private int CountClassMembers(int classId)
        {
            int count = 0;
            foreach (Raider raider in this)
            {
                if (raider.ClassId == classId)
                {
                    count++;
                }

            }
            return count;
        }

        public Raider FindRaider(string raiderName)
        {
            _raiderNameToFind = raiderName;
            return this.Find(RaiderFound);
        }

        private bool RaiderFound(Raider raider)
        {
            return string.Equals(_raiderNameToFind, raider.Name);
        }

        #endregion
    }
}
